import { ScrollView, View } from '@tarojs/components'
import { AtTabs } from "taro-ui"
import { getAppData } from '@utils/tools'
import { BasePage } from '@common/components/base-page'
// import  './index.scss'
import style from  './index.module.scss'
import { Platform } from '@utils/platform'

interface IProps {
    tabList: any
    tabPlatform?: boolean
}
interface IState {
    currentClick: string
    // tabList: any
}
export default class CommonTabs extends BasePage<IProps, IState> {
    constructor(props) {
        super(props);
        this.state = {
            currentClick: '0'
        }
    }
    handleClick(e) {
        this.setState({
            currentClick: e
        })
    }

    render() {
        const { tabList, tabPlatform } = this.props
        return (
            <ScrollView className={tabPlatform ? style.platTabs : style.tabsCon} enhanced={true} scrollX={true}>
                <View className={tabPlatform ? style.platBox : style.tabsBox}>
                    {
                        tabList.map(item => {
                            return (
                                <View onClick={this.handleClick.bind(this, item.key)} className={!tabPlatform?(item.key === this.state.currentClick ? style.tabsActive : ''):(item.key === this.state.currentClick ? style.platActive : '')}>{item.title}</View>
                            )
                        })
                    }
                </View>
            </ScrollView>
        )
    }
}